import { Merchant, MerchantFull } from '@shared/interfaces/merchant'
import { FormGroup, FormBuilder } from '@angular/forms'
import { MerchantStoreService } from './merchant-store.service'

export abstract class MerchantNewBaseClass {
  merchant: MerchantFull

  validateForm: FormGroup

  constructor(
    public fb: FormBuilder,
    public merchantStore: MerchantStoreService,
  ) {
    this.validateForm = this.fb.group({})
    this.initData()
  }

  initData(): void {
    this.merchantStore
      .value$
      .subscribe(merchant => this.merchant = merchant)
  }

  checkValid(): boolean {
    this.pushDataToStore()
    return true
  }

  abstract pushDataToStore(): void
}
